package com.onion.utils.support.counter;

public class CounterHelper {

    public static CircleCounter<Long> newCycleCounter(long start, long step, int count){
        Long[] array = newArray(start, step, count);
        return CircleCounter.instance(array);
    }

    public static StepCounter<Long> newStepCounter(long start, long step, int count){
        Long[] array = newArray(start, step, count);
        return StepCounter.instance(array);
    }

    private static Long[] newArray(long start, long step, int count){
        Long[] array = new Long[count];
        for(int i=0; i<count; i++){
            array[i] = start + i * step;
        }
        return array;
    }

    public static void main(String[] args){
        CircleCounter<Long> circleTimer = CounterHelper.newCycleCounter(11, 5, 10);
        StepCounter<Long> stepTimer = CounterHelper.newStepCounter(11, 5, 10);

        for(int i=0; i<50; i++){
            System.out.println(circleTimer.getAndNext() + "......" + stepTimer.getAndNext());
        }
    }

}